package com.bancomer.batch;

import java.io.File;
import java.util.Properties;

import com.bancomer.batch.pojo.Alert;
import com.bancomer.batch.pojo.AlertsContainer;
import com.bancomer.batch.pojo.PigScript;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.StaxDriver;

public class MapConstants {
	private static MapConstants mapConstants;
	private String pathConstantsFile = "";
	private final Properties constants;
	
	private MapConstants(String pathConstantsFile){
		this.pathConstantsFile = pathConstantsFile;
		XStream xstream = new XStream(new StaxDriver());
		xstream.alias("Properties", Properties.class);
		constants = (Properties) xstream.fromXML(new File(this.pathConstantsFile));
	}
	
	public static MapConstants getInstance(){
		return mapConstants;
	}
	
	public static MapConstants getInstance(String pathConstantsFile) throws Exception{
		if(mapConstants == null){
			mapConstants = new MapConstants(pathConstantsFile);
		}
		return mapConstants;
	}
	
	public Properties getConstants(){
		return constants;
	}
}
